<template>
  <div class="knowledge-node-card" ref="card">
    <!-- 删除蓝点锚点相关代码 -->
    <div class="header">
      <span class="icon"></span>
      <span class="title">知识库节点</span>
    </div>
    <div class="desc">从知识库中检索相关信息</div>
    <div class="section-title">知识库配置</div>
    <div class="config-list">
      <div class="config-row">
        <label>知识库：</label>
        <el-select v-model="config.knowledgeBase" size="small" style="width: 100%;" placeholder="请选择知识库">
          <el-option label="公司文档库" value="company" />
          <el-option label="技术文档库" value="tech" />
          <el-option label="产品手册库" value="product" />
        </el-select>
      </div>
      <div class="config-row">
        <label>检索方式：</label>
        <el-select v-model="config.searchType" size="small" style="width: 100%;">
          <el-option label="语义检索" value="semantic" />
          <el-option label="关键词检索" value="keyword" />
          <el-option label="混合检索" value="hybrid" />
        </el-select>
      </div>
      <div class="config-row">
        <label>检索数量：</label>
        <el-input-number v-model="config.topK" :min="1" :max="20" size="small" style="width: 100%;" />
      </div>
      <div class="config-row">
        <label>相似度阈值：</label>
        <el-slider v-model="config.similarityThreshold" :min="0" :max="1" :step="0.1" size="small" />
      </div>
    </div>
    <div class="section-title">查询内容</div>
    <div class="query-area">
      <el-input 
        v-model="config.query" 
        type="textarea" 
        :rows="3"
        placeholder="请输入查询内容，可使用 {变量名} 引用输入参数"
      />
    </div>
    <div class="section-title">输出配置</div>
    <div class="config-list">
      <div class="config-row">
        <el-checkbox v-model="config.saveToVariable">保存到变量</el-checkbox>
      </div>
      <div class="config-row" v-if="config.saveToVariable">
        <label>变量名：</label>
        <el-input v-model="config.outputVariable" size="small" placeholder="请输入输出变量名" />
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'KnowledgeBaseNodeCard',
  props: {
    config: {
      type: Object,
      required: true
    }
  },
  methods: {
  }
};
</script>

<style scoped>
.knowledge-node-card {
  width: 300px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 2px 8px 0 rgba(0,0,0,0.04);
  padding: 16px;
  position: relative;
}

.node-dot {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #2979ff;
  border: 2px solid #fff;
  box-shadow: 0 0 2px #2979ff;
  cursor: pointer;
  z-index: 10;
  transition: box-shadow 0.2s;
}

.node-dot--left-top {
  top: -6px;
  left: -6px;
}

.node-dot--right-top {
  top: -6px;
  right: -6px;
}

.node-dot:hover {
  box-shadow: 0 0 8px #2979ff;
}

.header {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
  position: relative;
}

.icon {
  width: 32px;
  height: 32px;
  background: #e3f2fd;
  border-radius: 50%;
  display: inline-block;
  margin-right: 8px;
  position: relative;
}

.icon::after {
  content: '📚';
  display: block;
  width: 16px;
  height: 16px;
  font-size: 16px;
  position: absolute;
  left: 8px;
  top: 8px;
}

.title {
  font-size: 18px;
  font-weight: bold;
}

.desc {
  color: #888;
  font-size: 13px;
  margin-bottom: 8px;
}

.section-title {
  font-weight: bold;
  margin-bottom: 8px;
  margin-top: 12px;
}

.section-title:first-of-type {
  margin-top: 0;
}

.config-list {
  background: #fafbfc;
  border-radius: 6px;
  padding: 12px;
}

.config-row {
  margin-bottom: 12px;
}

.config-row:last-child {
  margin-bottom: 0;
}

.config-row label {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
  color: #333;
}

.query-area {
  background: #fafbfc;
  border-radius: 6px;
  padding: 12px;
}
</style> 